import ajax from '@/utils/request'
import { concatUrl } from '@/utils'

type Field = string | object

// 搜索默认关键字
export function defaultKeyword(data?, fields: Field = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/search/search/default-keyword', fields),
    data
  })
}

// 热门搜索
export function hotSearch(data?, fields: Field = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/search/search/hot', fields),
    data
  })
}

// 历史搜索
export function historySearch(data?, fields: Field = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/search/search/history', fields),
    data
  })
}

// 清除历史搜索
export function clearHistorySearch(data?, fields: Field = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/search/search/clear', fields),
    data
  })
}

// 默认搜索关键字
export function searchRecommend(data?, fields: Field = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/search/search/default-keyword', fields),
    data
  })
}

// 搜索结果
export function search(data?, fields: Field = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/search/search/search', fields),
    data
  })
}
